<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
<link rel="stylesheet" href="/layui/css/layui.css">
<script src="/layui/layui.js"></script>
</head>
<body class="layui-layout-body" style="overflow-y: auto; overflow-x: hidden; margin-left: 10px; margin-right: 10px;">
<table class="layui-table">
  <thead>
    <tr>
      <th>序号</th>
      <th>提出者姓名</th>
      <th>提出时间</th>
      <th>疑问内容</th>
      <th width="90px" style="text-align: center;">处理</th>
    </tr> 
  </thead>
  <tbody>
    <tr th:each="topic:${reportTopics}" th:if="${reportTopics!=null}">
      <td>[[${topicStat.index+1}]]</td>
      <td>[[${topic.uname}]]</td>
      <td>[[${topic.rtime}]]</td>
      <td>[[${topic.rmessage}]]</td>
      <td style="text-align: center;">
      	<a class="layui-btn layui-btn-normal layui-btn-xs" th:attr="onclick='dispose(`'+${topic.rid}+'`);'">处理</a>
      	<a class="layui-btn layui-btn-danger layui-btn-xs" th:attr="onclick='exit(`'+${topic.rid}+'`);'">驳回</a>
      </td>
    </tr>
    <tr th:if="${reportTopics==null}">
      <td colspan="5" style="text-align: center;">暂无数据</td>
    </tr>
  </tbody>
</table>
<div style="text-align: center;" th:if="${reportTopics!=null}">
   <button type="button" class="layui-btn layui-btn-normal" th:attr="onclick='dispose2(`'+${reportTopics[0].tid}+'`);'">处理全部</button>
   <button class="layui-btn layui-btn-danger" th:attr="onclick='exit2(`'+${reportTopics[0].tid}+'`);'">驳回全部</button>
</div>
<script type="text/javascript">
var layer ;
layui.use(['layer', 'admin', 'form', 'laydate', 'fileChoose'], function () {
    layer = layui.layer;
});
function dispose(qid){
	layer.prompt({
		formType: 2,
		value: '',
		title: '请输入驳回得理由'
	}, function(value, index, elem){
		layer.close(index);
		disposeMessage(value,0,qid);
	});
}
function exit(qid){
	disposeMessage("管理员驳回了你的举报",0,qid);
}
function dispose2(qid){
	layer.prompt({
		formType: 2,
		value: '',
		title: '请输入驳回得理由'
	}, function(value, index, elem){
		layer.close(index);
		disposeMessage(value,1,qid);
	});
}

function exit2(qid){
	disposeMessage("管理员驳回了你的提问",1,qid);
}

function disposeMessage(value,count,id){
	let params = {};
    params.message = value;
    params.count = count;
    params.id = id;
    $.ajax( {
	        url : '/admin/topic/modification4', 
	        type : 'post',
	        data: params,
	        dataType : 'json',
	        success : function(data) {
	        	if(data.code==0){
        		 layer.msg(data.msg,{icon: 1});
        		 setTimeout(function(){
	        		 location.reload();
				 },1500);
        	 }else{
        		 layer.msg(data.msg,{icon: 2});
        	 }
		}
	});
}
	
</script>
</body>
</html>